package com.qidian.tcba.oss.dao;


import com.qidian.tcba.oss.model.Attachment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface AttachmentsMapper {
    int deleteByPrimaryKey(int id);

    int insert(Attachment record);

    Attachment selectByPrimaryKey(int id);

    List<Attachment> selectAll();

    int updateByPrimaryKey(Attachment record);


    /**
     * 新增 操作 方法
     *
     * @param attachments
     */
    int insertAttachments(@Param("attachments") List<Attachment> attachments);

    void deleteAttachmentsByIds(@Param("ids") List<Integer> ids);

    void deleteAttachmentsByOwner(@Param("ownerType") String ownerType, @Param("ownerId") int ownerId);

    List<Attachment> findByOwner(@Param("ownerType") String ownerType, @Param("ownerId") int ownerId);

    void deleteAttachmentsByExceptIds(@Param("ids") List<Integer> ids, @Param("ownerType") String ownerType, @Param("ownerId") int ownerId);

    int deleteAttachmentsByOwnerTypesAndId(@Param("ownerTypes") List<String> ownerTypes, @Param("ownerId") int ownerId);

    List<Attachment> findByOwnerTypesAndId(@Param("ownerTypes") List<String> ownerTypes, @Param("ownerId") int ownerId);

    int deleteAttachmentsByTypePrefixAndExcludeIds(@Param("ownerTypePrefix") String ownerTypePrefix, @Param("ownerId") int ownerId, @Param("excludeIds") List<Integer> excludeIds);

    List<Attachment> selectByPrefixAndOwnerId(@Param("typePrefix") String typePrefix, @Param("ownerId") int ownerId);

    List<Attachment> selectByIds(List<Integer> retainIds);

    List<Attachment> findByOwnerAndBusinessType(String ownerType, int ownerId,int businessType);

//    int deleteBySearch(AttachmentSearchParam searchParam);
//
//    List<Attachment> search(AttachmentSearchParam searchParam);

    List<Attachment> getAttachments(String ownerType, int ownerId);

    Attachment getAttachmentByPath(String path);

    /**
     * 关联附件
     * @param ownerId
     * @param ownerType
     * @param ids
     * @return
     */
    int relateAttach(@Param("ownerId") Integer ownerId, @Param("ownerType") String ownerType, @Param("ids") List<Integer> ids);

//    AttachmentBaseInfoDTO getAttachmentBaseInfo(String ownerType, int ownerId,@Param("name") String name);
}